package converter;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

import repository.SearchRepository;
import domain.SearchResultItem;

@Component
public class SearchResultItemConverter implements Converter<String, SearchResultItem>{
	
	private SearchRepository searchRepository;
	
	@Autowired
	public SearchResultItemConverter(SearchRepository searchRepository) {
		this.searchRepository = searchRepository;
	}

	@Override
	public SearchResultItem convert(String source) {
		return searchRepository.getSavedResultItem(Integer.valueOf(source));
	}

}
